package com.example.myapplication.test2;

import android.os.Bundle;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.example.myapplication.R;

import java.util.ArrayList;
import java.util.List;

public class Test2Activity extends AppCompatActivity {
    private static final String TAG = "MainActivity--->";
    private RecyclerView rv;
    private GroupListAdapter mAdapter;
    private List<CourseBean> mList;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();
        initData();
    }

    private void initView() {
        rv = findViewById(R.id.rv);
        rv.getItemAnimator().setChangeDuration(0);// 通过设置动画执行时间为0来解决闪烁问题
        LinearLayoutManager manager = new LinearLayoutManager(this);
        rv.setLayoutManager(manager);
        mAdapter = new GroupListAdapter();
        mAdapter.bindAdapterToRecyclerView(rv);

    }

    private void initData() {
        mList = new ArrayList<>();

        mList.add(new CourseBean(1621052498L, false));
        mList.add(new CourseBean(1620188498L, true));
        mList.add(new CourseBean(1617596498L, true));
        mList.add(new CourseBean(1637596498L, false));
        mList.add(new CourseBean(1647596498L, true));
        mList.add(new CourseBean(1657596498L, false));
        mList.add(new CourseBean(1667596498L, false));
        mList.add(new CourseBean(1677596498L, false));
        mList.add(new CourseBean(1687596498L, true));
        mList.add(new CourseBean(1689596498L, false));
        mList.add(new CourseBean(1680596498L, true));
        mList.add(new CourseBean(1681596498L, false));
        mList.add(new CourseBean(1682596498L, false));
        mList.add(new CourseBean(1684596498L, false));
        mList.add(new CourseBean(1685596498L, false));
        mList.add(new CourseBean(1686596498L, false));
        mList.add(new CourseBean(1687596498L, false));
        mList.add(new CourseBean(1688596498L, false));
        mList.add(new CourseBean(1689596498L, false));
        mList.add(new CourseBean(1680596498L, false));
        mList.add(new CourseBean(1681596498L, true));
        mList.add(new CourseBean(1682596498L, false));
        mList.add(new CourseBean(1683596498L, false));
        mList.add(new CourseBean(1684596498L, false));
        mList.add(new CourseBean(1685596498L, false));
            mAdapter.setNewData(mList);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        mAdapter.destroy();
    }
}
